package com.dg.gaming.tictactoe.common
{
	import com.dg.gaming.api.common.msg.MsgTableMessage;

	import nanoxml.XMLElement;

	public class MsgTicTacToeMove extends MsgTableMessage
	{
		public static const XML_NAME:String="tic_tac_toe";

		private static const XML_ATT_X:String="x";

		private static const XML_ATT_Y:String="y";

		private static const XML_ATT_VALUE:String="value";

		private var x:int;

		private var y:int;

		private var value:int;

		public function MsgTicTacToeMove(x:int=-1, y:int=-1, value:int=-1, message:XMLElement=null)
		{
			this.x=x;
			this.y=y;
			this.value=value;
			if (message != null)
			{
				super(message);
				this.x=message.getIntAttribute(XML_ATT_X);
				this.y=message.getIntAttribute(XML_ATT_Y);
				this.value=message.getIntAttribute(XML_ATT_VALUE);
			}
		}

		// Flatten the fields of this object into a String
		public override function flatten():XMLElement
		{
			var message:XMLElement=super.flattenWithName(XML_NAME);
			message.setIntAttribute(XML_ATT_X, x);
			message.setIntAttribute(XML_ATT_Y, y);
			message.setIntAttribute(XML_ATT_VALUE, value);

			return message;
		}

		public function getX():int
		{
			return x;
		}

		public function getY():int
		{
			return y;
		}

		public function getValue():int
		{
			return value;
		}
	}
}